﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ScreenConditioner
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ConditionWindow _cWin;

        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
            this.Closed += new EventHandler(MainWindow_Closed);
        }

        void MainWindow_Closed(object sender, EventArgs e)
        {
            Properties.Settings.Default.IsMaximized = (_cWin.WindowState == System.Windows.WindowState.Maximized);
            _cWin.WindowState = System.Windows.WindowState.Normal;
            Properties.Settings.Default.Save();
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (_cWin == null)
            {
                _cWin = new ConditionWindow();
            }
            _cWin.Show();
            if (Properties.Settings.Default.IsMaximized)
                _cWin.WindowState = System.Windows.WindowState.Maximized;
        }

        bool _windowCycling = false;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (_windowCycling)
            {
                this.CyclingButton.Content = " Start Cycling Window ";
                _cWin.StopTimer();
                _windowCycling = false;
            }
            else
            {
                this.CyclingButton.Content = " Stop Cycling Window ";
                _cWin.StartTimer();
                _windowCycling = true;
            }
        }
    }
}
